﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:viewmodels="clr-namespace:Analyzer.ViewModels;assembly=Analyzer.ViewModels"
                    xmlns:views="clr-namespace:Analyzer.Views;assembly=Analyzer.Views">

    <DataTemplate DataType="{x:Type viewmodels:EntityViewModel}">
        <views:EntityView/>
    </DataTemplate>
    <DataTemplate DataType="{x:Type viewmodels:AnalyzerViewModel}">
        <views:AnalyzerView/>
    </DataTemplate>
    <DataTemplate DataType="{x:Type viewmodels:MyComputerTreeViewModel}">
        <views:MyComputerView/>
    </DataTemplate>
    <DataTemplate x:Key="ClosableTabItemTemplate" DataType="viewmodels:AnalyzerViewModel">
        <DockPanel Width="100">
            <Button Command="{Binding Path=CloseCommand}" Cursor="Hand" DockPanel.Dock="Right" Focusable="False"
                        FontFamily="Courier" FontSize="9" FontWeight="Bold" BorderBrush="Transparent" 
                        Margin="0,1,0,0" Padding="0" VerticalContentAlignment="Bottom"
                        Height="20" ToolTipService.HasDropShadow="True">
                <Image Source="Icons/DeleteIcon.png"/>
            </Button>
            <TextBlock Text="{Binding DisplayName}" FontFamily="Buxton Sketch"
                       FontSize="12"
                       VerticalAlignment="Center"/>            
        </DockPanel>        
    </DataTemplate>
            
    <DataTemplate DataType="{x:Type viewmodels:StatusbarLoadingViewModel}">
        <views:CircularLoadingControlView/>
    </DataTemplate>

    <DataTemplate DataType="{x:Type viewmodels:StatusbarWorkCompleteViewModel}">
        <views:StatusBarWorkCompleteView/>
    </DataTemplate>

    <viewmodels:ElementTypeToImageConverter x:Key="ElementTypeToImageConverter"/>

    <Style TargetType="{x:Type TabItem}" x:Key="TabItemStyle">
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="IsSelected" Value="True"/>               
            </Trigger>
        </Style.Triggers>
    </Style>
    <DataTemplate DataType="{x:Type viewmodels:ItemLoadingViewModel}">
        <views:ItemLoadingView/>
    </DataTemplate>
    <LinearGradientBrush x:Key="LinearBrush" StartPoint="0.5,0" EndPoint="0.5,1">
        <GradientStop Color="White" Offset="0.0" />
        <GradientStop Color="WhiteSmoke" Offset="0.25" />
        <GradientStop Color="Silver" Offset="0.5" />
        <GradientStop Color="#ff595959" Offset="0.75" />
        <GradientStop Color="#ff333333" Offset="1.0" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="LinearBrushHeader" StartPoint="0.5,0" EndPoint="0.5,1">
        <GradientStop Color="Wheat" Offset="0" />
        <GradientStop Color="WhiteSmoke" Offset="0.25" />
        <GradientStop Color="Bisque" Offset="0.5" />
        <GradientStop Color="WhiteSmoke" Offset="0.75" />
        <GradientStop Color="Wheat" Offset="1.0" />
    </LinearGradientBrush>
    <Style TargetType="Button">
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Opacity" Value=".5"/>
            </Trigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="{x:Type ToolTip}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToolTip}">
                    <Border BorderBrush="#111111"
                          BorderThickness="1"
                          SnapsToDevicePixels="True">
                        <Border Width="Auto" Height="Auto" Name="windowFrame" BorderBrush="#999999"
                          BorderThickness="1" SnapsToDevicePixels="True" CornerRadius="0" 
                          Background="SlateGray"  TextBlock.Foreground="White" TextBlock.FontFamily="Verdana" 
                            TextBlock.FontSize="11" Margin="0" Padding="3">
                            <ContentPresenter />
                        </Border>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="TextBlock" x:Key="StatusBarTextBlock">
        <Setter Property="TextWrapping" Value="NoWrap" />
        <Setter Property="TextTrimming" Value="CharacterEllipsis" />
        <Setter Property="Padding" Value="2,0" />
    </Style>
    <Style TargetType="Separator" BasedOn="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}">
        <Setter Property="Margin" Value="2,0" />
    </Style>
    <Style TargetType="{x:Type MenuItem}">
        <!-- Property trigger - Reacts on WPF property-->
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="Firebrick"/>
            </Trigger>
        </Style.Triggers>
    </Style>
    <!-- Tab Control Style-->

    <viewmodels:ContentToMarginConverter x:Key="content2MarginConverter"/>
    <viewmodels:ContentToPathConverter x:Key="content2PathConverter"/>

    <SolidColorBrush x:Key="BorderBrush" Color="#FFFFFFFF"/>
    <SolidColorBrush x:Key="HoverBrush" Color="#ff333333"/>
    <LinearGradientBrush x:Key="TabControlBackgroundBrush" EndPoint="0.5,0" StartPoint="0.5,1">
        <GradientStop Color="#FFa9cde7" Offset="0"/>
        <GradientStop Color="#FFe7f4fc" Offset="0.3"/>
        <GradientStop Color="#FFf2fafd" Offset="0.85"/>
        <GradientStop Color="#FFe4f6fa" Offset="1"/>        
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="TabItemPathBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#FF3164a5" Offset="0"/>
        <GradientStop Color="#FFe4f6fa" Offset="1"/>
    </LinearGradientBrush>

    <!-- TabControl style -->
    <Style x:Key="TabControlStyle" TargetType="{x:Type TabControl}">
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TabControl">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Border Grid.Row="1" BorderThickness="2,0,2,2" Panel.ZIndex="2" CornerRadius="0,0,2,2"
                                BorderBrush="{StaticResource BorderBrush}"
                                Background="{StaticResource TabControlBackgroundBrush}">
                            <ContentPresenter ContentSource="SelectedContent"/>
                        </Border>
                        <StackPanel Orientation="Horizontal" Grid.Row="0" Panel.ZIndex="1" IsItemsHost="true"/>
                        <Rectangle Grid.Row="0" Height="2" VerticalAlignment="Bottom"
                                   Fill="{StaticResource BorderBrush}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!-- TabItem style -->
    <Style x:Key="{x:Type TabItem}" TargetType="{x:Type TabItem}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TabItem">
                    <Grid x:Name="grd">
                        <Path x:Name="TabPath" StrokeThickness="2"
                              Margin="{Binding ElementName=TabItemContent, Converter={StaticResource content2MarginConverter}}"
                              Stroke="{StaticResource BorderBrush}"
                              Fill="{StaticResource TabItemPathBrush}">
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure IsClosed="False" StartPoint="1,0" 
                                                Segments="{Binding ElementName=TabItemContent, Converter={StaticResource content2PathConverter}}">
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                            <Path.LayoutTransform>
                                <ScaleTransform ScaleY="-1"/>
                            </Path.LayoutTransform>
                        </Path>
                        <Rectangle x:Name="TabItemTopBorder" Height="2" Visibility="Visible"
                                   VerticalAlignment="Bottom" Fill="{StaticResource BorderBrush}"
                                   Margin="{Binding ElementName=TabItemContent, Converter={StaticResource content2MarginConverter}}" />
                        <ContentPresenter x:Name="TabItemContent" ContentSource="Header"
                                          Margin="10,2,10,2" VerticalAlignment="Center"
                                          TextElement.Foreground="Black"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True" SourceName="grd">
                            <Setter Property="Stroke" Value="{StaticResource HoverBrush}" TargetName="TabPath"/>
                        </Trigger>
                        <Trigger Property="Selector.IsSelected" Value="True">
                            <Setter Property="Fill" TargetName="TabPath">
                                <Setter.Value>
                                    <SolidColorBrush Color="#FFe4f6fa"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="BitmapEffect">
                                <Setter.Value>
                                    <DropShadowBitmapEffect Direction="302" Opacity="0.4" 
                                                        ShadowDepth="2" Softness="0.5"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Panel.ZIndex" Value="2"/>
                            <Setter Property="Visibility" Value="Hidden" TargetName="TabItemTopBorder"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>